package com.hsmw.api.controller.biz;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import com.hsmw.api.controller.pub.RedisCache;
import com.hsmw.api.mapper.*;
import com.hsmw.api.service.*;
import com.hsmw.api.utils.GaoDeInfoUtils;
import com.hsmw.api.vo.DriverAndVehicleVO;
import com.hsmw.api.vo.DriverInfoVO;
import com.hsmw.api.vo.HomeVolume;
import com.hsmw.api.vo.RelationOrderVo;
import com.hsmw.common.base.BaseController;
import com.hsmw.common.base.BasePage;
import com.htn.common.core.base.DataResponse;
import com.htn.common.core.constant.CommonConstants;
import com.htn.common.core.constant.OrderStatusEnum;
import com.htn.common.core.utils.StringUtils;
import com.hsmw.domain.*;
import com.hsmw.domain.form.GetObjectByIdForm;
import com.hsmw.domain.vo.GpsInfoEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;

/**
 * @author WD
 */
@Api(tags = "BIZ-司机管理")
@RestController
@RequestMapping("/api/biz/driver")
public class BizUserDriverController extends BaseController<HsmwUserDriverService, HsmwUserDriver> {

	@Autowired
	private HsmwUserDriverService hsmwUserDriverService;
	@Autowired
	private HsmwOrderVehicleRelationMapper hsmwOrderVehicleRelationMapper;
	@Autowired
	private HsmwVehicleService hsmwVehicleService;

	@Autowired
	private HsmwComplainMapper hsmwComplainMapper;

	@Autowired
	private HsmwReportMapper hsmwReportMapper;

	@Autowired
	private HsmwUserDriverMapper hsmwUserDriverMapper;

	@Autowired
	private HsmwVehicleRefuelingMapper hsmwVehicleRefuelingMapper;

	@Autowired
	private HsmwPointsDetailsMapper hsmwPointsDetailsMapper;

	@Autowired
	private HsmwDriverOrderRecordMapper hsmwDriverOrderRecordMapper;

	@Autowired
	private HsmwDriverClassService hsmwDriverClassService;

	@Autowired
	private HsmwGoodsOrderService hsmwGoodsOrderService;

	@Autowired
	private HsmwDriverUserMapper hsmwDriverUserMapper;

	@Autowired
	private RedisTemplate redisTemplate;

	@Autowired
	private HsmwAuditService hsmwAuditService;
	//private static Long sumCount = 0L;


	/**
	 * 获取司机分页列表
	 *
	 * @param basePage
	 * @return
	 */
	@ApiOperation(value = "BIZ-获取司机分页列表", notes = "获取司机分页列表", produces = "application/json")
	@PostMapping("/getBizHsmwDriverPage")
	public DataResponse getBizHsmwDriverPage(@RequestBody @Valid BasePage<DriverInfoVO> basePage) {
		IPage page = new Page(basePage.getPageNo(), basePage.getPageSize());
		DriverInfoVO driverInfoVO = basePage.getRequestData();
		IPage<DriverInfoVO> data = hsmwUserDriverService.getBizHsmwDriverPage(page, driverInfoVO);
		List<DriverInfoVO> records = data.getRecords();
		for (DriverInfoVO record : records) {
			String vehicleId = record.getId();
			List<Double> sumVolume = hsmwOrderVehicleRelationMapper.findSumVolume(vehicleId);
			record.setVolumeMontyCount(sumVolume.get(0).intValue());
		}
		return new DataResponse(data);
	}

	/**
	 * 车俩下拉列表
	 *
	 * @return
	 */
	@ApiOperation(value = "BIZ-车俩下拉列表", notes = "车俩下拉列表", produces = "application/json")
	@PostMapping("/getDriverVehicleSelect")
	public DataResponse getBizVehicleSelect() {
		List<HsmwVehicle> result = hsmwVehicleService.getDriverVehicleSelect();
		return new DataResponse(result);
	}

	/**
	 * 根据ID查询数据
	 *
	 * @param form
	 * @return
	 */
	@ApiOperation(value = "根据id查询数据", notes = "根据id查询数据", produces = "application/json")
	@PostMapping("/getBizDriverById")
	public DataResponse getLeasingCompanyById(@RequestBody GetObjectByIdForm form) {
		DriverInfoVO driverInfoVO = hsmwUserDriverService.getBizDriverById(form.getKey());
		String driverId = driverInfoVO.getId();
		String vehicleId = driverInfoVO.getVehicleId();
		List<Double> sumVolume = hsmwOrderVehicleRelationMapper.findSumVolume(driverId);
		HsmwVehicle byId = hsmwVehicleService.getById(vehicleId);
		if(byId != null){
			if (StringUtils.isNotBlank(byId.getImeiNum()) || StringUtils.isNotBlank(byId.getIdentifyingCode())) {
				GpsInfoEntity entity = GaoDeInfoUtils.getSingleVehicleGpsLocate(byId.getImeiNum(),byId.getFlag(), byId.getIdentifyingCode());
				if (StringUtils.isNotNull(entity) && StringUtils.isNotBlank(entity.getGpsLon())) {
					byId.setImeiNumLocate(entity.getGpsLon() + "," + entity.getGpsLat());
				}
				if(StringUtils.isNotBlank(byId.getImeiNumLocate())){
					String nameByGps = GaoDeInfoUtils.gaodeGetNameByGps(byId.getImeiNumLocate());
					byId.setVehicleAddress(nameByGps);
				}
			}else {
				byId.setImeiNumLocate(byId.getMobileLocate());
				String nameByGps = GaoDeInfoUtils.gaodeGetNameByGps(byId.getImeiNumLocate());
				byId.setVehicleAddress(nameByGps);
			}
			driverInfoVO.setHsmwVehicle(byId);
		}
		driverInfoVO.setVolumeMontyCount(sumVolume.get(0).intValue());
		Long sumComCount = 0L;
		List<HsmwOrderVehicleRelation> hsmwOrderVehicleRelations = hsmwOrderVehicleRelationMapper.selectList(new LambdaQueryWrapper<HsmwOrderVehicleRelation>().eq(HsmwOrderVehicleRelation::getVehicleId, vehicleId));
		for (HsmwOrderVehicleRelation hsmwOrderVehicleRelation : hsmwOrderVehicleRelations) {
			String orderId = hsmwOrderVehicleRelation.getOrderId();
			List<HsmwComplain> hsmwComplains = hsmwComplainMapper.selectList(new LambdaQueryWrapper<HsmwComplain>().eq(HsmwComplain::getOrderId, orderId));
			sumComCount += hsmwComplains.size();
		}
		driverInfoVO.setSumComCount(sumComCount);
		List<HsmwReport> hsmwReports = hsmwReportMapper.selectList(new LambdaQueryWrapper<HsmwReport>().eq(HsmwReport::getDriId, form.getKey()));
		driverInfoVO.setHsmwReports(hsmwReports);

		Double sumDriverVolume =  0.0;
		Double sumComfirmVolume = 0.0;

		List<HsmwDriverOrderRecord> hsmwDriverOrderRecords = hsmwDriverOrderRecordMapper.findDriverOrderListByDriverId(form.getKey(),form.getMonth());

		for (HsmwDriverOrderRecord hsmwDriverOrderRecord : hsmwDriverOrderRecords) {
			String confirmVolume = hsmwDriverOrderRecord.getSettlementVolume();
			String driverVolume1 = hsmwDriverOrderRecord.getRealVolume();
			sumDriverVolume += Double.valueOf(driverVolume1);
			sumComfirmVolume += Double.valueOf(confirmVolume);
		}
		Integer vehicleFaultCount = hsmwReportMapper.selectCount(new LambdaQueryWrapper<HsmwReport>().eq(HsmwReport::getDriId, form.getKey()).eq(HsmwReport::getReportType, "2"));

		Integer trafficAccidentCount = hsmwReportMapper.selectCount(new LambdaQueryWrapper<HsmwReport>().eq(HsmwReport::getDriId, form.getKey()).eq(HsmwReport::getReportType, "3"));
		driverInfoVO.setTrafficCount(trafficAccidentCount);
		driverInfoVO.setVehicleCount(vehicleFaultCount);
		driverInfoVO.setSumDriverVolume(sumDriverVolume);
		driverInfoVO.setSumComfirmVolume(sumComfirmVolume);
		driverInfoVO.setRelationOrderVos(hsmwDriverOrderRecords);

		List<HsmwGoodsOrder> goodsOrders = hsmwGoodsOrderService.list(new LambdaQueryWrapper<HsmwGoodsOrder>().eq(HsmwGoodsOrder::getDriverId, form.getKey()));
		if(CollectionUtil.isNotEmpty(goodsOrders)){
			driverInfoVO.setHsmwGoodsOrders(goodsOrders);
		}
		return new DataResponse(driverInfoVO);
	}


	/**
	 * 新增
	 * 修改  必须带ID
	 *
	 * @param driverInfoVO
	 * @return
	 */
	@ApiOperation(value = "新增/修改", notes = "新增：传对象；修改：传id；", produces = "application/json")
	@PostMapping("/saveOrUpdateHsmwDriver")
	public DataResponse saveOrUpdateHsmwDriver(@RequestBody @Valid DriverInfoVO driverInfoVO) {
		return hsmwUserDriverService.saveOrUpdateHsmwDriver(driverInfoVO);
	}

	/**
	 * 司机数据汇总
	 *
	 * @param basePage
	 * @return
	 */
	@ApiOperation(value = "司机数据汇总", notes = "司机数据汇总", produces = "application/json")
	@PostMapping("/getDriverDataCollect")
	public DataResponse getDriverDataCollect(@RequestBody @Valid BasePage<DriverInfoVO> basePage) {
		IPage page = new Page(basePage.getPageNo(), basePage.getPageSize());
		DriverInfoVO queryData = basePage.getRequestData();
		if (queryData.getQueryDate() == null) {
			queryData.setQueryDate(new Date());
		}
		IPage<DriverInfoVO> driverInfoVOIPage = hsmwUserDriverService.getBizHsmwDriverPage(page, queryData);
		Set<String> driverUserIdSet = driverInfoVOIPage.getRecords().stream().map(DriverInfoVO::getId).collect(Collectors.toSet());
		if (CollectionUtil.isNotEmpty(driverUserIdSet)) {
			List<HsmwOrderVehicleRelation> hsmwOrderVehicleRelationList = hsmwOrderVehicleRelationMapper.selectList(
					Wrappers.lambdaQuery(HsmwOrderVehicleRelation.class)
							.in(HsmwOrderVehicleRelation::getDriverId, driverUserIdSet)
							.between(HsmwOrderVehicleRelation::getEndTime, DateUtil.beginOfMonth(queryData.getQueryDate()), DateUtil.endOfMonth(queryData.getQueryDate())));
			Map<String, List<HsmwOrderVehicleRelation>> orderDriverMap = hsmwOrderVehicleRelationList.stream().collect(Collectors.groupingBy(HsmwOrderVehicleRelation::getDriverId));
			driverInfoVOIPage.getRecords().stream().forEach(driverInfoVO -> {
				driverInfoVO.setQueryDate(queryData.getQueryDate());
				if (orderDriverMap.get(driverInfoVO.getId()) != null) {
					//月订单
					driverInfoVO.setOrderMontyCount(orderDriverMap.get(driverInfoVO.getId()).size());
					//当月方量
					Integer volumeMontyCount = orderDriverMap.get(driverInfoVO.getId()).stream()
							.map(HsmwOrderVehicleRelation::getDriverVolume)
							.filter(StrUtil::isNotBlank)
							.map(Integer::parseInt)
							.reduce(0, (a, b) -> a + b);
					driverInfoVO.setVolumeMontyCount(volumeMontyCount);
					//取消订单
					List<HsmwOrderVehicleRelation> cancelOrderMontyList = orderDriverMap.get(driverInfoVO.getId()).stream().filter(x -> x.getOrderStatus().equals(OrderStatusEnum.CANCELED.getValue())).collect(Collectors.toList());
					driverInfoVO.setCancelOrderMontyCount(Optional.ofNullable(cancelOrderMontyList).orElse(Lists.newArrayList()).size());
					//迟到
					List<HsmwOrderVehicleRelation> lateOrderMontyList = orderDriverMap.get(driverInfoVO.getId()).stream()
							.filter(x -> x.getClockInTime() != null && x.getReachTime() != null)
							.filter(x -> x.getClockInTime().isAfter(x.getReachTime()))
							.collect(Collectors.toList());
					driverInfoVO.setLateOrderMontyCount(Optional.ofNullable(lateOrderMontyList).orElse(Lists.newArrayList()).size());
				}
			});
		}
		return new DataResponse(driverInfoVOIPage);
	}


	@ApiOperation(value = "车辆加油统计", notes = "车辆加油统计", produces = "application/json")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "params", value = "按周:1 月:2 年:3 分组", dataType = "String"),
			@ApiImplicitParam(name = "id", value = "车辆id", dataType = "String"),
	})
	@PostMapping("/findVehicleRefuelingById")
	public DataResponse findVehicleRefuelingById(String params,String id){
		if (StringUtils.isBlank(params)) {
			return new DataResponse(CommonConstants.ResponseStatus.FAIL, "参数错误");
		}
		Map map = new HashMap();
		AtomicReference<Long> sumCount = new AtomicReference<>(0L);
		if (StringUtils.equals("1", params)) {

 			List<HomeVolume> homeVolumes = hsmwVehicleRefuelingMapper.findFulVolumeDriverWeek(id);
			homeVolumes.stream().forEach(homeVolume -> {
				String[] weekDays = { "周天", "周一", "周二", "周三", "周四", "周五", "周六" };
				Calendar cal = Calendar.getInstance();
				Date date = new Date();
				cal.setTime(date.from(homeVolume.getEndTime().atZone( ZoneId.systemDefault()).toInstant()));
				int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
				if (w < 0)
					w = 0;
				homeVolume.setWeekName(weekDays[w]);
				if(homeVolume.getForemanVolume() == null){
					homeVolume.setForemanVolume("0");
				}
				sumCount.updateAndGet(v -> v + Double.valueOf(homeVolume.getForemanVolume()).longValue());
			});
			map.put("orderTrend",homeVolumes);
			map.put("sumCount",sumCount.get());

		}

		if (StringUtils.equals("2", params)) {
			List<JSONObject> orderTrend = Lists.newArrayList();
			LocalDate localDate = LocalDate.now();
			//这个月的第一天
			Date monthStart = Date.from(localDate.with(TemporalAdjusters.firstDayOfMonth()).atStartOfDay(ZoneId.systemDefault()).toInstant());
			//这个月的最后一天 下个月的第一天
			Date monthEnd = Date.from(localDate.plusMonths(1).with(TemporalAdjusters.firstDayOfMonth()).atStartOfDay(ZoneId.systemDefault()).toInstant());

			DateTime endTime = DateUtil.date(monthEnd);
			DateTime startTime = DateUtil.date(monthStart);
			List<HsmwVehicleRefueling> hsmwOrderList = hsmwVehicleRefuelingMapper.selectList(
					Wrappers.lambdaQuery(HsmwVehicleRefueling.class)
							.between(HsmwVehicleRefueling::getSubmitTime, DateUtil.beginOfDay(startTime), DateUtil.endOfDay(endTime)).eq(HsmwVehicleRefueling::getDriverId,id)
			);
			hsmwOrderList.forEach(x -> x.setStatisticsTime(DateUtil.format(Date.from(x.getSubmitTime().atZone(ZoneId.systemDefault()).toInstant()), "yyyy-MM-dd")));

			Calendar calendar = Calendar.getInstance();
			calendar.setTime(endTime);
			calendar.add(Calendar.DATE,-1);
			Date dateEndtime =calendar.getTime();
			Map<String, List<HsmwVehicleRefueling>> statisticsMap = hsmwOrderList.stream().collect(Collectors.groupingBy(HsmwVehicleRefueling::getStatisticsTime));
			List<String> dayBetween = com.htn.common.core.utils.DateUtil.getDayBetween(DateUtil.format(startTime.toJdkDate(), "yyyy-MM-dd"), DateUtil.format(dateEndtime, "yyyy-MM-dd"));

			for (String day : dayBetween) {
				AtomicInteger count = new AtomicInteger();
				JSONObject jsonObject = new JSONObject();
				jsonObject.put("day", day);
				if (statisticsMap.get(day) != null) {
					List<HsmwVehicleRefueling> orderList = statisticsMap.get(day);
					orderList.stream().forEach(x -> {
						if (StrUtil.isNotBlank(x.getFuelVolume())) {
							String foremanVolume = x.getFuelVolume();
							count.addAndGet(Integer.valueOf(foremanVolume));
						}
					});
				}
				jsonObject.put("count", count);
				orderTrend.add(jsonObject);
			}
			map.put("orderTrend",orderTrend);
			hsmwOrderList.stream().forEach(hsmwOrder -> {
				sumCount.updateAndGet(v -> v + Long.parseLong(hsmwOrder.getFuelVolume()));
			});
			map.put("sumCount",sumCount.get());
		}


		return new DataResponse(map);
	}


	@ApiOperation(value = "车辆项目占比 按周 月  分组", notes = "车辆项目占比 按周 月  分组", produces = "application/json")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "params", value = "月份", dataType = "String"),
			@ApiImplicitParam(name = "id", value = "车辆id", dataType = "String"),
	})
	@PostMapping("findItemPercentageByVehicleId")
	public DataResponse findItemPercentageByVehicleId(String id, String params) {

		if (StringUtils.isBlank(params)) {
			return new DataResponse(CommonConstants.ResponseStatus.FAIL, "参数错误");
		}
		Map map = new HashMap();

		List<HomeVolume> homeVolumes = hsmwUserDriverService.findItemPerOnMonth(id,params);
		map.put("homeVolumes", homeVolumes);

		return new DataResponse(map);
	}


	@ApiOperation(value = "方量月统计", notes = "方量月统计", produces = "application/json")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "month", value = "月份", dataType = "String"),
			@ApiImplicitParam(name = "id", value = "车辆id", dataType = "String"),
	})
	@PostMapping("/findVehicleVolumeByMonth")
	public DataResponse findVehicleVolumeByMonth(String id,String month){
		Map map = new HashMap();
		StringBuffer stringBuffer = new StringBuffer(month);
		StringBuffer append = stringBuffer.append("-01");
		String s = LocalDate.now().toString();
		String[] split = s.split("-");
		String s1 = split[0];
		StringBuffer buffer = new StringBuffer(s1+"-");
		StringBuffer date = buffer.append(append);
		String s2 = date.toString();
		LocalDate localDate = LocalDate.parse(s2, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
		//这个月的第一天
		Date monthStart = Date.from(localDate.with(TemporalAdjusters.firstDayOfMonth()).atStartOfDay(ZoneId.systemDefault()).toInstant());
		//这个月的最后一天 下个月的第一天
		Date monthEnd = Date.from(localDate.plusMonths(1).with(TemporalAdjusters.firstDayOfMonth()).atStartOfDay(ZoneId.systemDefault()).toInstant());
		DateTime endTime = DateUtil.date(monthEnd);
		DateTime startTime = DateUtil.date(monthStart);
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(endTime);
		calendar.add(Calendar.DATE,-1);
		Date dateEndtime =calendar.getTime();
		List<HomeVolume> homeVolumes = hsmwUserDriverService.findVehicleVolumeByMonth(id,month);
		List<String> dayBetween = com.htn.common.core.utils.DateUtil.getDayBetween(DateUtil.format(startTime.toJdkDate(), "yyyy-MM-dd"), DateUtil.format(dateEndtime, "yyyy-MM-dd"));
		map.put("month",dayBetween);
		map.put("homeVolume",homeVolumes);
		return new DataResponse(map);
	}



	@ApiOperation(value = "积分统计", notes = "积分统计", produces = "application/json")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "id", value = "司机id", dataType = "String")
	})
	@PostMapping("/findPointsDetailsById")
	public DataResponse findPointsDetailsById(String id){

		Map map = new HashMap();
		List<JSONObject> orderTrend = Lists.newArrayList();
		LocalDate localDate = LocalDate.now();
		//这个月的第一天
		Date monthStart = Date.from(localDate.with(TemporalAdjusters.firstDayOfMonth()).atStartOfDay(ZoneId.systemDefault()).toInstant());
		//这个月的最后一天 下个月的第一天
		Date monthEnd = Date.from(localDate.plusMonths(1).with(TemporalAdjusters.firstDayOfMonth()).atStartOfDay(ZoneId.systemDefault()).toInstant());

		DateTime endTime = DateUtil.date(monthEnd);
		DateTime startTime = DateUtil.date(monthStart);
		List<HsmwPointsDetails> hsmwOrderList = hsmwPointsDetailsMapper.selectList(
				Wrappers.lambdaQuery(HsmwPointsDetails.class)
						.between(HsmwPointsDetails::getCreateTime, DateUtil.beginOfDay(startTime), DateUtil.endOfDay(endTime)).eq(HsmwPointsDetails::getDriverId,id)
		);
		hsmwOrderList.forEach(x -> x.setStatisticsTime(DateUtil.format(Date.from(x.getCreateTime().atZone(ZoneId.systemDefault()).toInstant()), "yyyy-MM-dd")));

		Map<String, List<HsmwPointsDetails>> statisticsMap = hsmwOrderList.stream().collect(Collectors.groupingBy(HsmwPointsDetails::getStatisticsTime));
		List<String> dayBetween = com.htn.common.core.utils.DateUtil.getDayBetween(DateUtil.format(startTime.toJdkDate(), "yyyy-MM-dd"), DateUtil.format(endTime.toJdkDate(), "yyyy-MM-dd"));
		AtomicReference<Long> sumCount = new AtomicReference<>(0L);
		for (String day : dayBetween) {
			AtomicInteger count = new AtomicInteger();
			JSONObject jsonObject = new JSONObject();
			jsonObject.put("day", day);
			if (statisticsMap.get(day) != null) {
				List<HsmwPointsDetails> orderList = statisticsMap.get(day);
				orderList.stream().forEach(x -> {
					if (x.getTypeIntegral() != null) {
						BigDecimal foremanVolume = x.getTypeIntegral();
						count.addAndGet(foremanVolume.intValue());
					}
				});
			}
			jsonObject.put("count", count);
			orderTrend.add(jsonObject);
		}
		map.put("orderTrend",orderTrend);
		hsmwOrderList.stream().forEach(hsmwOrder -> {
			sumCount.updateAndGet(v -> v + hsmwOrder.getTypeIntegral().longValue());
		});
		map.put("sumCount",sumCount.get());
		map.put("list",hsmwOrderList);
		return new DataResponse(map);
	}


	@ApiOperation(value = "删除司机 ", notes = "删除司机", produces = "application/json")
	@PostMapping("/deleteHsmwDriver")
	public DataResponse deleteHsmwDriver(@RequestBody GetObjectByIdForm form){

		if(form.getKey() == null){
			return new DataResponse(CommonConstants.ResponseStatus.FAIL,"id不能为空");
		}
		HsmwUserDriver userdri = hsmwUserDriverService.getById(form.getKey());
		if(StringUtils.isNotBlank(userdri.getUserId())){
			HsmwDriverUser user = hsmwDriverUserMapper.selectById(userdri.getUserId());
			user.setUsername("中控删除司机");
			hsmwDriverUserMapper.updateById(user);
			hsmwAuditService.remove(new LambdaQueryWrapper<HsmwAudit>().eq(HsmwAudit::getUserId,user.getId()));
			redisTemplate.delete(user.getId());
		}
		boolean del = hsmwUserDriverService.removeById(form.getKey());
		if(del){
			return new DataResponse(CommonConstants.ResponseStatus.SUCCESS,"删除成功");
		}
		return new DataResponse(CommonConstants.ResponseStatus.FAIL,"删除失败");

	}


	@ApiOperation(value = "获取车辆列表 ", notes = "获取车辆列表", produces = "application/json")
	@PostMapping("/findHsmwVehicleList")
	public DataResponse findHsmwVehicleList(){
		List<HsmwVehicle> list = hsmwVehicleService.list();
		return new DataResponse(list);
	}


	@ApiOperation(value = "司机学习图表展示 ", notes = "司机学习图表展示", produces = "application/json")
	@ApiImplicitParam(value = "司机id",name = "id",dataType = "String")
	@PostMapping("/findDriverClassInfoById")
	public DataResponse findDriverClassInfoById(String id){

		List<HsmwDriverClass> list = hsmwDriverClassService.list(new LambdaQueryWrapper<HsmwDriverClass>().eq(HsmwDriverClass::getDriverId, id));
		return new DataResponse(list);
	}


}
